home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
pd
/
netz
/
term
/
extras
/
source
/
term-source.lha
/
ImportPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-15
|
7KB
|
342 lines
/*
** ImportPanel.c
**
** Editing panel for phone unit settings
**
** Copyright © 1990-1995 by Olaf `Olsen' Barthel
** All Rights Reserved
*/
#include "termGlobal.h"
enum { GAD_LIST=1,GAD_REPLACE,GAD_APPEND,GAD_CANCEL };
/* ListViewRender():
*
* This callback routine is responsible for rendering
* the single listview entries.
*/
STATIC ULONG __saveds __asm
ListViewRender(register __a0 struct Hook *Hook,register __a1 struct LVDrawMsg *Msg,register __a2 struct Node *Node)
{
/* We only know how to redraw lines. */
if(Msg -> lvdm_MethodID == LV_DRAW)
{
struct RastPort *RPort = Msg -> lvdm_RastPort;
LONG Left = Msg -> lvdm_Bounds . MinX,
Top = Msg -> lvdm_Bounds . MinY,
Width = Msg -> lvdm_Bounds . MaxX - Msg -> lvdm_Bounds . MinX + 1,
Height = Msg -> lvdm_Bounds . MaxY - Msg -> lvdm_Bounds . MinY + 1,
FgPen,BgPen,
Len,LabelLen;
STRPTR String;
String = &Node -> ln_Name[6];
/* Determine the rendering pens. */
switch(Msg -> lvdm_State)
{
case LVR_SELECTEDDISABLED:
case LVR_NORMALDISABLED:
case LVR_NORMAL:
FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[TEXTPEN];
BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[BACKGROUNDPEN];
break;
case LVR_SELECTED:
FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLTEXTPEN];
BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLPEN];
break;
}
SetAPen(RPort,BgPen);
RectFill(RPort,Left,Top,Left + 1,Top + Height - 1);
Left += 2;
Width -= 2;
/* Set the rendering pens. */
SetDrMd(RPort,JAM2);
SetAPen(RPort,FgPen);
SetBPen(RPort,BgPen);
/* Determine length of vanilla name. */
LabelLen = strlen(String);
/* Try to make it fit. */
while(LabelLen > 0 && (Len = TextLength(RPort,String,LabelLen)) > Width)
LabelLen--;
/* Print the vanilla name if possible. */
if(LabelLen)
{
Move(RPort,Left,Top + RPort -> Font -> tf_Baseline);
Text(RPort,String,LabelLen);
Left += Len;
Width -= Len;
}
/* Fill the area to follow the vanilla name. */
if(Width > 0)
{
SetAPen(RPort,BgPen);
RectFill(RPort,Left,Top,Left + Width - 1,Top + Height - 1);
}
/* If the item happens to be disabled, draw the cross-hatch
* pattern across it.
*/
if(Msg -> lvdm_State == LVR_SELECTEDDISABLED || Msg -> lvdm_State == LVR_NORMALDISABLED)
{
SetDrMd(RPort,JAM1);
SetAPen(RPort,Msg -> lvdm_DrawInfo -> dri_Pens[BLOCKPEN]);
SetAfPt(RPort,(UWORD *)&Ghosting,1);
RectFill(RPort,Msg -> lvdm_Bounds . MinX,Msg -> lvdm_Bounds . MinY,Msg -> lvdm_Bounds . MaxX,Msg -> lvdm_Bounds . MaxY);
SetAfPt(RPort,NULL,0);
}
return(LVCB_OK);
}
else
return(LVCB_UNKNOWN);
}
BYTE __regargs
ImportPanel(struct PhoneEntry *Entry,struct List *PhoneList,struct List *TimeDateList)
{
struct LayoutHandle *Handle;
BYTE MadeChanges = FALSE;
if(!TimeDateList)
TimeDateList = (struct List *)&Entry -> TimeDateList;
if(Handle = LT_CreateHandleTags(Window -> WScreen,
LH_LocaleHook, &LocaleHook,
TAG_DONE))
{
struct Window *PanelWindow;
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, VERTICAL_KIND,
LA_LabelID, MSG_V36_0088,
TAG_DONE);
{
STATIC struct Hook ListViewHook =
{
{NULL},
(HOOKFUNC)ListViewRender
};
LONG i,Index = -1;
for(i = 0 ; i < NumPhoneEntries ; i++)
{
if(Entry == Phonebook[i])
{
Index = i;
break;
}
}
LT_New(Handle,
LA_Type, LISTVIEW_KIND,
LA_LabelID, MSG_GLOBAL_NAME_LIST_GAD,
LA_ID, GAD_LIST,
LA_Chars, 50,
LA_Lines, 10,
LALV_Link, NIL_LINK,
LALV_CursorKey, TRUE,
LALV_MaxGrowY, 20,
LALV_ResizeY, TRUE,
GTLV_Selected, Index,
GTLV_CallBack, &ListViewHook,
GTLV_Labels, PhoneList,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type,VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, XBAR_KIND,
LAXB_FullSize, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,LA_Type,HORIZONTAL_KIND,
LAGR_Spread, TRUE,
TAG_DONE);
{
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_IMPORTPANEL_REPLACE_RATES_GAD,
LA_ID, GAD_REPLACE,
GA_Disabled, TRUE,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_IMPORTPANEL_APPEND_RATES_GAD,
LA_ID, GAD_APPEND,
GA_Disabled, TRUE,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_CANCEL_GAD,
LA_ID, GAD_CANCEL,
LABT_EscKey, TRUE,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
if(PanelWindow = LT_Layout(Handle,LocaleString(MSG_IMPORTPANEL_IMPORT_RATES_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
LAWN_HelpHook, &GuideHook,
LAWN_Parent, Window,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_DragBar, TRUE,
WA_RMBTrap, TRUE,
WA_Activate, TRUE,
TAG_DONE))
{
struct IntuiMessage *Message;
BOOLEAN Done = FALSE;
ULONG MsgClass,
MsgQualifier;
UWORD MsgCode;
struct Gadget *MsgGadget;
LONG Selected = ~0;
GuideContext(CONTEXT_IMPORT);
LT_ShowWindow(Handle,TRUE);
PushWindow(PanelWindow);
do
{
if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
break;
while(Message = (struct IntuiMessage *)LT_GetIMsg(Handle))
{
MsgClass = Message -> Class;
MsgQualifier = Message -> Qualifier;
MsgCode = Message -> Code;
MsgGadget = (struct Gadget *)Message -> IAddress;
LT_ReplyIMsg(Message);
if(MsgClass == IDCMP_CLOSEWINDOW)
Done = TRUE;
if(MsgClass == IDCMP_GADGETUP)
{
switch(MsgGadget -> GadgetID)
{
case GAD_LIST:
if(Entry != Phonebook[MsgCode])
{
if(Selected == ~0)
{
LT_SetAttributes(Handle,GAD_REPLACE,
GA_Disabled, FALSE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_APPEND,
GA_Disabled, FALSE,
TAG_DONE);
}
Selected = MsgCode;
}
else
{
if(Selected != ~0)
{
LT_SetAttributes(Handle,GAD_REPLACE,
GA_Disabled, TRUE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_APPEND,
GA_Disabled, TRUE,
TAG_DONE);
Selected = ~0;
}
}
break;
case GAD_APPEND:
CopyTimeDateList((struct List *)&Phonebook[Selected] -> TimeDateList,TimeDateList,TRUE);
Done = MadeChanges = TRUE;
break;
case GAD_REPLACE:
FreeTimeDateList(TimeDateList);
CopyTimeDateList((struct List *)&Phonebook[Selected] -> TimeDateList,TimeDateList,FALSE);
Done = MadeChanges = TRUE;
break;
case GAD_CANCEL:
Done = TRUE;
break;
}
}
}
}
while(!Done);
PopWindow();
}
LT_DeleteHandle(Handle);
}
return(MadeChanges);
}